import gulpError from './utils/gulpError';
import http from './utils/http'
App({
    onShow() {
      if (gulpError !== 'gulpErrorPlaceHolder') {
          wx.redirectTo({
              url: `/pages/gulp-error/index?gulpError=${gulpError}`,
          });
      }
    },
    func:{
      request: http.request
    },
    onShareAppMessage() {
      return {
        title: '财务小管家'
      }
    },
    onLaunch(){
      const miniProgram = wx.getAccountInfoSync()
      const newVersion = miniProgram.miniProgram.version || '1.0.0'
      const oldVersion = wx.getStorageSync('_version')||'1.0.0'
      const updateManager = wx.getUpdateManager()
      if(oldVersion != newVersion){
        wx.showModal({
          title: '更新提示',
          content: '新版本已经准备好，是否重启应用？',
          showCancel:false,
          success:()=>{
            wx.setStorageSync('_version', newVersion)
            updateManager.applyUpdate()
            wx.showToast({
              title: '更新成功',
              icon: 'success',
              duration: 500
            })            
          }
        });
      }
    }
});
